//
//  MainVC.m
//  XTeng
//
//  Created by 周成龙 on 16/8/11.
//  Copyright © 2016年 ZCL. All rights reserved.
//

#import "MainVC.h"

#import "TabBarVC.h"
#import "ClassTabBaeVC.h"
#import "VDJConstant.h"

#import "NoticeHeader.h"

@interface MainVC ()
@end

@implementation MainVC
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.navBarView setHidden:YES];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTabBar:) name:kChangeTabBar  object:nil];
    [self addViewControllers];
    TabBarVC *vc = self.childViewControllers[0];
    [self.view addSubview:vc.view];
}

- (void)addViewControllers
{
    TabBarVC *tabBar = [[TabBarVC alloc] init];
    [self addChildViewController:tabBar];
    [tabBar didMoveToParentViewController:self];
    
    ClassTabBaeVC *classTabBar = [[ClassTabBaeVC alloc] init];
    [self addChildViewController:classTabBar];
    [classTabBar didMoveToParentViewController:self];
}

- (void)changeTabBar:(NSNotification *)note
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.5];
    NSString *isTest = note.object[@"value"];
    if (kStringAIsEqualToStringB(isTest, @"isTest")) {
        
        ClassTabBaeVC *vc = self.childViewControllers[1];
        [self.view addSubview:vc.view];
        TabBarVC *vc1 = self.childViewControllers[0];
        [vc1.view removeFromSuperview];
    }else {
        TabBarVC *vc = self.childViewControllers[0];
        [self.view addSubview:vc.view];
        ClassTabBaeVC *vc1 = self.childViewControllers[1];
        [vc1.view removeFromSuperview];
    }
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
    [UIView commitAnimations];
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

@end
